# encoding = utf-8

from application.logging import logger
from application.model.v3_model.CV_Parameter_online.get_best_params_ import get_best_params_
from application.utils.CodeTimingUtil import CodeTimingUtil


@CodeTimingUtil(name="[调参]CV_n_estimators")
def CV_n_estimators(train_x, train_y):
    #
    cv_params = {
        "n_estimators": [
            50, 60, 70, 80, 90, 100,
            150, 200, 300, 400, 500, 600, 700, 800, 900, 1000,
            1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000,
            2100, 2200, 2300, 2400, 2500, 3000,
            4000
        ]
    }
    #
    other_params = {
        "learning_rate": 0.05,
        "n_estimators": 1600,
        "max_depth": 2,
        "min_child_weight": 1,
        "seed": 0,
        "subsample": 1,
        "colsample_bytree": 0.6,
        "gamma": 0,
        "reg_alpha": 0.03,
        "reg_lambda": 0.03
    }
    #
    logger.info(f"调参开始[n_estimators]: {'*' * 50}")
    best_params_ = get_best_params_(train_x=train_x, train_y=train_y, cv_params=cv_params, other_params=other_params)
    n_estimators = best_params_["n_estimators"]
    logger.info(f"调参结束[n_estimators]:[{n_estimators}] {'*' * 50}")
    #
    return n_estimators
    pass


pass

# if ->
if __name__ == '__main__':
    pass  # <- if

pass
